<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="./../layui/css/layui.css" media="all">
    <script src="./../layui/layui.js"></script>
    <script src="./../js/jquery-1.8.3.min.js"></script>
    <script src="./../js/env.js"></script>
    <title>充电记录</title>
</head>
<fieldset class="layui-elem-field layui-field-title">
    <legend>充电记录</legend>
</fieldset>
<div class="demoTable">
    <button type="button" class="layui-btn" style="margin-left: 10px;margin-bottom: 10px" onclick="javascript :history.back(-1)">返回</button>
</div>
<body>
<table id="demo" lay-filter="test"></table>
</body>

</html>
<script>

    if (layui.sessionData('user').userInfo === undefined) {
        window.location.href = "../html/login.html"
    }

    layui.use('table', function () {
        var table = layui.table;
        var whereData = {};
        //充电桩id
        whereData.id = getParam("id");
        //代理ID
        whereData.agentUserId = layui.sessionData("user").userInfo.id;
        //代理商或管理员查询地址
        var url = getParam("url");
        //第一个实例
        table.render({
            elem: '#demo'
            , id: 'testReload'
            , where: whereData
            , headers: {sessionId: getToken()}
            , height: 312
            , url: abc() + url //数据接口
            , page: true //开启分页
            , cols: [[ //表头
                {field: 'id', title: 'id', sort: true, fixed: 'left',width:90, align: 'center'}
                , {field: 'stockUserId', title: '充电用户ID',width:111,  align: 'center'}
                , {field: 'chargingStationsId', title: '充电站ID',width:111,  align: 'center'}
                , {field: 'chargingPileInfoId', title: '充电桩ID',width:111, align: 'center'}
                , {field: 'province', title: '省',width:80, align: 'center'}
                , {field: 'city', title: '市',width:80, align: 'center'}
                , {field: 'county', title: '县',width:80, align: 'center'}
                , {field: 'address', title: '详细地点',width:111, align: 'center'}
                , {field: 'price', title: '价格单位(元)',width:111, align: 'center'}
                , {field: 'serviceCharge', title: '服务费价格单位元/度',width:175, align: 'center'}
                , {field: 'createTime', title: '创建时间',width:111, align: 'center'}
                , {field: 'timestamp', title: '修改时间',width:111, align: 'center'}
                , {field: 'chargeStartTime', title: '充电开始时间',width:135, align: 'center'}
                , {field: 'chargeEndTime', title: '充电结束时间',width:135, align: 'center'}
                , {field: 'chargeTotalMoney', title: '充电总金额',width:125, align: 'center'}
                , {field: 'chargeNum', title: '充电总度数', width:125,align: 'center'}
                , {field: 'stationName', title: '充电站名字',width:125, align: 'center'}
                , {field: 'serialNumber', title: '编号',width:90, align: 'center'}
                , { field: 'nickname', title: '用户昵称',width:90, align: 'center' }
                , {field: 'username', title: '真实姓名',width:90, align: 'center'}
                , {field: 'tel', title: '手机号',width:90, align: 'center'}

            ]]
            , request: {
                pageName: 'page' //页码的参数名称，默认：page
                , limitName: 'pageSize' //每页数据量的参数名，默认：limit
            }
            ,done: function(res, curr, count){
                if (res.code ===100) {
                    layer.msg("登录失效，请重新登录")
                    window.location.href = "../html/login.html"
                    return;
                }
            }
            , parseData: function (res) { //res 即为原始返回的数据
                if (res.code !== 0) {
                    return {
                        "code": res.code, //解析接口状态
                        "msg": res.msg //解析提示文本
                    };
                } else {
                    return {
                        "code": res.code, //解析接口状态
                        "msg": res.msg, //解析提示文本
                        "count": res.data.total, //解析数据长度
                        "data": res.data.list //解析数据列表
                    };
                }

            }
        });

    });
</script>
